/*
 * Lenovo Group
 * Copyright (c) 2015-2016 All Rights Reserved.
 * Project Name: lmrp-android app
 * Create Time: 16-2-16 下午6:38
 */

package com.lenovo.mso2o.entity;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by hejie5 on 2016/2/2.
 */
public class OrderStatus implements Serializable{
    private Date[] value;
    private String code;
    public Date[] getValue() {
        return value;
    }

    public void setValue(Date[] value) {
        this.value = value;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String toString() {
        if(value != null && value.length == 2 && value[0] != null && value[1] != null) {
            Date first = value[0];
            Date last = value[1];
            long duration = 0;
            if (System.currentTimeMillis() < first.getTime())
                //预先提醒
                duration = first.getTime() - System.currentTimeMillis();
            else if (System.currentTimeMillis() > last.getTime())
                //超时提醒
                duration = System.currentTimeMillis() - last.getTime();
            else
                return "";
            StringBuilder builder = new StringBuilder();
            android.support.v4.util.TimeUtils.formatDuration(duration, builder);
            return code + ":" + builder.toString();
        }
        return "";
    }
}
